Fixes #4293
authorxftroxgpx <xftroxgpx@gmail.com>
Tue, 18 Jul 2017 13:05:35 +0000 (15:05 +0200)
committerxftroxgpx <xftroxgpx@gmail.com>
Tue, 18 Jul 2017 13:12:54 +0000 (15:12 +0200)
locally tested with:
cargo test legacy_ many_crate_types_old_style_lib_location

src/cargo/util/toml/targets.rs
tests/bench.rs
tests/build.rs

index 498bb66370452ded79c7165db8f0f9ab2f49dd1c..599913c8cea4af76234e3b854a20df5927a5ba24 100644 (file)
@@ -16,7 +16,6 @@ use std::collections::HashSet;
 use core::Target;
 use ops::is_bad_artifact_name;
 use util::errors::CargoResult;
-use util::paths::without_prefix;
 use super::{TomlTarget, LibKind, PathValue, TomlManifest, StringOrBool,
             TomlLibTarget, TomlBinTarget, TomlBenchTarget, TomlExampleTarget, TomlTestTarget};
 
@@ -106,13 +105,10 @@ fn clean_lib(toml_lib: Option<&TomlLibTarget>,
             let legacy_path = package_root.join("src").join(format!("{}.rs", lib.name()));
             if legacy_path.exists() {
                 {
-                    let short_path = without_prefix(&legacy_path, package_root)
-                        .unwrap_or(&legacy_path);
-
                     warnings.push(format!(
                         "path `{}` was erroneously implicitly accepted for library `{}`,\n\
                          please rename the file to `src/lib.rs` or set lib.path in Cargo.toml",
-                        short_path.display(), lib.name()
+                        legacy_path.display(), lib.name()
                     ));
                 }
                 legacy_path
@@ -178,13 +174,10 @@ fn clean_bins(toml_bins: Option<&Vec<TomlBinTarget>>,
         let path = target_path(bin, &inferred, "bin", package_root, &mut |_| {
             if let Some(legacy_path) = legacy_bin_path(package_root, &bin.name(), has_lib) {
                 {
-                    let short_path = without_prefix(&legacy_path, package_root)
-                        .unwrap_or(&legacy_path);
-
                     warnings.push(format!(
                         "path `{}` was erroneously implicitly accepted for binary `{}`,\n\
                          please set bin.path in Cargo.toml",
-                        short_path.display(), bin.name()
+                        legacy_path.display(), bin.name()
                     ));
                 }
                 Some(legacy_path)
@@ -268,13 +261,10 @@ fn clean_benches(toml_benches: Option<&Vec<TomlBenchTarget>>,
             return None;
         }
         {
-            let short_path = without_prefix(&legacy_path, package_root)
-                .unwrap_or(&legacy_path);
-
             warnings.push(format!(
                 "path `{}` was erroneously implicitly accepted for benchmark `{}`,\n\
                  please set bench.path in Cargo.toml",
-                short_path.display(), bench.name()
+                legacy_path.display(), bench.name()
             ));
         }
         Some(legacy_path)
index 094bcb3d7b623250d481f85982c3765da1a55a6c..cf68a629eee3dd14b692a7680bea5cebdad191da 100644 (file)
@@ -1186,6 +1186,6 @@ fn legacy_bench_name() {
         "#);
 
     assert_that(p.cargo_process("bench"), execs().with_status(0).with_stderr_contains("\
-[WARNING] path `src[/]bench.rs` was erroneously implicitly accepted for benchmark `bench`,
+[WARNING] path `[..]src[/]bench.rs` was erroneously implicitly accepted for benchmark `bench`,
 please set bench.path in Cargo.toml"));
 }
index d56c70073ed24f3e35ac9a94a8e943603c87f1e7..59a7e451777d963e8865fe4182f6172e9ee2c310 100644 (file)
@@ -1047,7 +1047,7 @@ fn many_crate_types_old_style_lib_location() {
             pub fn foo() {}
         "#);
     assert_that(p.cargo_process("build"), execs().with_status(0).with_stderr_contains("\
-[WARNING] path `src[/]foo.rs` was erroneously implicitly accepted for library `foo`,
+[WARNING] path `[..]src[/]foo.rs` was erroneously implicitly accepted for library `foo`,
 please rename the file to `src/lib.rs` or set lib.path in Cargo.toml"));
 
     assert_that(&p.root().join("target/debug/libfoo.rlib"), existing_file());
@@ -1402,7 +1402,7 @@ fn legacy_binary_paths_warinigs() {
         .file("src/main.rs", "fn main() {}");
 
     assert_that(p.cargo_process("build").arg("-v"), execs().with_status(0).with_stderr_contains("\
-[WARNING] path `src[/]main.rs` was erroneously implicitly accepted for binary `bar`,
+[WARNING] path `[..]src[/]main.rs` was erroneously implicitly accepted for binary `bar`,
 please set bin.path in Cargo.toml"));
 
     let mut p = project("world");
@@ -1419,7 +1419,7 @@ please set bin.path in Cargo.toml"));
         .file("src/bin/main.rs", "fn main() {}");
 
     assert_that(p.cargo_process("build").arg("-v"), execs().with_status(0).with_stderr_contains("\
-[WARNING] path `src[/]bin[/]main.rs` was erroneously implicitly accepted for binary `bar`,
+[WARNING] path `[..]src[/]bin[/]main.rs` was erroneously implicitly accepted for binary `bar`,
 please set bin.path in Cargo.toml"));
 
     let mut p = project("world");
@@ -1435,7 +1435,7 @@ please set bin.path in Cargo.toml"));
         .file("src/bar.rs", "fn main() {}");
 
     assert_that(p.cargo_process("build").arg("-v"), execs().with_status(0).with_stderr_contains("\
-[WARNING] path `src[/]bar.rs` was erroneously implicitly accepted for binary `bar`,
+[WARNING] path `[..]src[/]bar.rs` was erroneously implicitly accepted for binary `bar`,
 please set bin.path in Cargo.toml"));
 }